package com.appwoo.txtws.adapter;

import android.content.Intent;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.widget.AbsListView.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.appwoo.txtws.activity.BookReaderQuestionActivity;
import com.appwoo.txtws.activity.BookmarkActivity;
import com.appwoo.txtws.activity.WinInTestBookActivity;
import com.appwoo.txtws.bean.BookBean;
import java.util.ArrayList;

public class WinInTestBookAdapter extends BaseAdapter
{
  private View.OnClickListener bookmarkOnClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      BookBean localBookBean = (BookBean)paramAnonymousView.getTag();
      Intent localIntent = new Intent(WinInTestBookAdapter.this.context, BookmarkActivity.class);
      localIntent.putExtra("bookId", localBookBean.getBookId());
      localIntent.putExtra("bookname", localBookBean.getName());
      WinInTestBookAdapter.this.context.startActivity(localIntent);
    }
  };
  private ArrayList<BookBean> books;
  private WinInTestBookActivity context;
  private int firstExtra;
  private int height;
  private LayoutInflater inflater;
  private View.OnClickListener layoutOnClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      WinInTestBookAdapter.ViewHolderWinInTestBook localViewHolderWinInTestBook = (WinInTestBookAdapter.ViewHolderWinInTestBook)paramAnonymousView.getTag();
      Intent localIntent = new Intent(WinInTestBookAdapter.this.context, BookReaderQuestionActivity.class);
      localIntent.putExtra("bookname", localViewHolderWinInTestBook.book.getName());
      localIntent.putExtra("readerType", "local");
      WinInTestBookAdapter.this.context.startActivity(localIntent);
    }
  };
  private View.OnLongClickListener layoutOnLongClickListener = new View.OnLongClickListener()
  {
    public boolean onLongClick(View paramAnonymousView)
    {
      WinInTestBookAdapter.ViewHolderWinInTestBook localViewHolderWinInTestBook = (WinInTestBookAdapter.ViewHolderWinInTestBook)paramAnonymousView.getTag();
      WinInTestBookAdapter.this.context.showLongClickDialog(localViewHolderWinInTestBook.book);
      return false;
    }
  };

  public WinInTestBookAdapter(WinInTestBookActivity paramWinInTestBookActivity, ArrayList<BookBean> paramArrayList, int paramInt1, int paramInt2)
  {
    this.context = paramWinInTestBookActivity;
    this.books = paramArrayList;
    this.height = paramInt1;
    this.firstExtra = paramInt2;
    this.inflater = ((LayoutInflater)this.context.getSystemService("layout_inflater"));
  }

  public int getCount()
  {
    return this.books.size();
  }

  public Object getItem(int paramInt)
  {
    return this.books.get(paramInt);
  }

  public long getItemId(int paramInt)
  {
    return paramInt;
  }

  public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
  {
    ViewHolderWinInTestBook localViewHolderWinInTestBook;
    if (paramView == null)
    {
      localViewHolderWinInTestBook = new ViewHolderWinInTestBook();
      paramView = this.inflater.inflate(2130903237, null);
      localViewHolderWinInTestBook.tvBookname = ((TextView)paramView.findViewById(2131493663));
      localViewHolderWinInTestBook.ivBookmark = ((ImageView)paramView.findViewById(2131493664));
      localViewHolderWinInTestBook.layoutHaveNotBook = ((LinearLayout)paramView.findViewById(2131493665));
      localViewHolderWinInTestBook.ivHaveNotBook = ((ImageView)paramView.findViewById(2131493666));
      paramView.setTag(localViewHolderWinInTestBook);
      if (paramInt != 0)
        break label262;
      paramView.setLayoutParams(new AbsListView.LayoutParams(-1, this.height + this.firstExtra));
      label112: BookBean localBookBean = (BookBean)this.books.get(paramInt);
      if (localBookBean == null)
        break label294;
      localViewHolderWinInTestBook.tvBookname.setVisibility(0);
      localViewHolderWinInTestBook.ivBookmark.setVisibility(0);
      localViewHolderWinInTestBook.layoutHaveNotBook.setVisibility(8);
      localViewHolderWinInTestBook.ivHaveNotBook.setVisibility(8);
      localViewHolderWinInTestBook.book = localBookBean;
      paramView.setOnClickListener(this.layoutOnClickListener);
      paramView.setOnLongClickListener(this.layoutOnLongClickListener);
      if (localViewHolderWinInTestBook.book.getIsRead() != 1)
        break label281;
      localViewHolderWinInTestBook.ivBookmark.setBackgroundResource(2130838120);
      label213: localViewHolderWinInTestBook.ivBookmark.setTag(localBookBean);
      localViewHolderWinInTestBook.ivBookmark.setOnClickListener(this.bookmarkOnClickListener);
      localViewHolderWinInTestBook.tvBookname.setText(localBookBean.getName());
    }
    label262: label281: label294: 
    do
    {
      return paramView;
      localViewHolderWinInTestBook = (ViewHolderWinInTestBook)paramView.getTag();
      break;
      paramView.setLayoutParams(new AbsListView.LayoutParams(-1, this.height));
      break label112;
      localViewHolderWinInTestBook.ivBookmark.setBackgroundResource(2130838121);
      break label213;
      localViewHolderWinInTestBook.tvBookname.setVisibility(8);
      localViewHolderWinInTestBook.ivBookmark.setVisibility(8);
      localViewHolderWinInTestBook.ivBookmark.setOnClickListener(null);
      localViewHolderWinInTestBook.layoutHaveNotBook.setVisibility(8);
      localViewHolderWinInTestBook.ivHaveNotBook.setVisibility(8);
      paramView.setOnClickListener(null);
      paramView.setOnLongClickListener(null);
    }
    while (paramInt != 0);
    localViewHolderWinInTestBook.layoutHaveNotBook.setVisibility(0);
    localViewHolderWinInTestBook.ivHaveNotBook.setVisibility(0);
    localViewHolderWinInTestBook.ivHaveNotBook.setImageDrawable(this.context.getResources().getDrawable(2130837986));
    return paramView;
  }

  public void setData(ArrayList<BookBean> paramArrayList)
  {
    this.books = paramArrayList;
  }

  class ViewHolderWinInTestBook
  {
    BookBean book;
    ImageView ivBookmark;
    ImageView ivHaveNotBook;
    LinearLayout layoutHaveNotBook;
    TextView tvBookname;

    ViewHolderWinInTestBook()
    {
    }
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.adapter.WinInTestBookAdapter
 * JD-Core Version:    0.6.2
 */